repo.or.cz
/
andmenj-acm.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
Solving 10385 - Duathlon (Ternary search)
[andmenj-acm.git]
/
10295 - Hay Points
/
10295.cpp
blob
d20ae71a3f76decf190e6d7c61e495772c5f5d90
1
#include <map>
2
#include <iostream>
3
#include <string>
4
5
using namespace
std
;
6
7
int
main
(){
8
int
words
,
jobs
;
9
map
<
string
,
unsigned long long
>
dict
;
10
string s
;
11
unsigned long long
d
;
12
cin
>>
words
>>
jobs
;
13
for
(
int
i
=
0
;
i
<
words
; ++
i
){
14
cin
>>
s
>>
d
;
15
dict
[
s
] =
d
;
16
}
17
18
while
(
jobs
--){
19
unsigned long long
total
=
0
;
20
while
(
cin
>>
s
&&
s
!=
"."
){
21
map
<
string
,
unsigned long long
>::
iterator i
=
dict
.
find
(
s
);
22
if
(
i
!=
dict
.
end
()){
23
total
+=
i
->
second
;
24
}
25
}
26
cout
<<
total
<<
endl
;
27
}
28
return
0
;
29
}